// hyb_yl/backstageServices/pages/chufangjianyi/chufangjianyi.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    xufang: "",
    counttime: "",
    copyright: [{
        imgs: "https://6a69-jin5201-a4503e-1257013711.tcb.qcloud.la/renzheng.png?sign=99d87d2d65c67c848a10aaf43bafb66e&t=1583825248",
        text: "药监认证"
      },
      {
        imgs: "https://6a69-jin5201-a4503e-1257013711.tcb.qcloud.la/people.png?sign=717fc4019448bfc2a03ac538022f7ed8&t=1583825298",
        text: "药师审核"
      },
      {
        imgs: "https://6a69-jin5201-a4503e-1257013711.tcb.qcloud.la/yinsi.png?sign=f45888dbb9b06874e8d079f99d6018f5&t=1583825342",
        text: "隐私包装"
      },
    ]
  },
  loogchufang(e) {
    console.log(e)
    var that = this
    var id = that.data.id
    var cfimg = e.currentTarget.dataset.cfimg
    console.log(cfimg)
    app.util.request({
      url: 'entry/wxapp/user.gongzhangimg',
      data: {
        id: id,
        cfimg: cfimg
      },
      success: function (res) {
        console.log(res)
        wx.previewImage({
          urls: [res.data],
        })
      }
    })
  },
  atpay(e) {
    var that = this
    var id = that.data.id
    if (that.data.xufang == '1') {
      wx.navigateTo({
        url: '/hyb_yl/userCommunicate/pages/sure_Details/sure_Details?id=' + id + '&xufang=1',
      })
    } else {
      wx.navigateTo({
        url: '/hyb_yl/userCommunicate/pages/sure_Details/sure_Details?id=' + id + '&xufang=0',
      })
    }

  },
  countDown(times) {
    var timer = null;
    var self = this;
    timer = setInterval(function () {
      var hour = 0,
        minute = 0,
        second = 0; //时间默认值
      if (times > 0) {
        // day = Math.floor(times / (60 * 60 * 24));
        hour = Math.floor(times / (60 * 60));
        minute = Math.floor(times / 60) - (hour * 60);
        second = Math.floor(times) - (hour * 60 * 60) - (minute * 60);
      }
      // if (day <= 9) day = '0' + day;
      if (hour <= 9) hour = '0' + hour;
      if (minute <= 9) minute = '0' + minute;
      if (second <= 9) second = '0' + second;
      //
      self.setData({
        counttime: hour + ":" + minute + ":" + second
      })
      times--;
    }, 1000);
    if (times <= 0) {
      clearInterval(timer);
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var id = options.id
    var orderStatus = options.orderStatus

    that.setData({
      orderStatus: orderStatus,
      id: id,
    })
    app.util.request({
      url: 'entry/wxapp/user.cfdetail',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res)
        that.setData({
          conets: res.data.conets,
          goodlist: res.data.sid,
          cfimg: res.data.cfimg
        })
      }
    })
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    if (options.xufang) {
      this.setData({
        xufang: options.xufang
      })
    }
    that.setData({
      bgc: bgc
    })
    this.countDown(55555)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})